<?php
require_once(dirname(__FILE__)."/../include/common.inc.php");
require_once(DEDEINC.'/channelunit.class.php');
require_once(DEDEINC.'/taglib/arcpagelist.lib.php');
$pnum = empty($pnum)? 0 : intval(preg_replace("/[^\d]/",'', $pnum));
$typeid = empty($typeid)? 0 : $typeid;
if($typeid==0 || $pnum==0) die(" Request Error1! ");
if($typeid > 0)
{
	$titlelen = AttDef($titlelen,30);
	$infolen = AttDef($infolen,160);
	$imgwidth = AttDef($imgwidth,120);
	$imgheight = AttDef($imgheight,120);
	$listtype = AttDef($listtype,'all');
	$arcid = AttDef($arcid,0);
	$channelid = AttDef($channelid,0);
	$orderby = AttDef($orderby,'default');
	$orderWay = AttDef($order,'desc');
	$subday = AttDef($subday,0);
	$line = $row;
	$artlist = "";
	//通过页面及总数解析当前页面数据范围
	$strnum = ($pnum-1) * 4;
	$limitsql = " LIMIT $strnum,4 ";
	$innertext = '<div class="am-u-sm-6 am-u-md-3 list_work" style="float:left;">
					<div class="list_works">
					
							<div class="rem0_5"><a href="view.php?aid=[field:id/]"><img src="[field:litpic/]" class="am-img-responsive work_img" /></a></div>
							
							<span class="work_title"><a href="view.php?aid=[field:id/]" target="_blank" title="[field:title /]">[field:title /]</a></span>
							
							<div class="work_user">
								<img src="[field:mid function="face(@me)"/]" class="work_user_hp"/>
								<span class="work_user_name"><a title="织梦模板" >织梦模板</a></span>
								<i class="zt-recommend work_home_tj"></i>
								</div>			  			
							<div class="work_rq">
								<img src="/assets/images/icon_1.png" /> <span > [field:click/] </span>
								<img src="/assets/images/icon_2.png" /> <span > [field:id runphp="yes"] $aid = @me; $row = $GLOBALS["dsql"]->GetOne("Select count(id) as c from qm_feedback where aid=".@me); @me=$row["c"];[/field:id] </span>
								<img src="/assets/images/icon_3.png" /> <span > [field:id runphp="yes"] $aid = @me; $row = $GLOBALS["dsql"]->GetOne("Select count(id) as c from qm_member_stow where aid=".@me); @me=$row["c"];[/field:id] </span>
							</div>
					</div>
				</div>';//模板
	//处理列表内容项
	$query = "SELECT arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,
	tp.moresite,tp.siteurl,tp.sitepath FROM `#@__archives` arc LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id
	WHERE arc.typeid IN (".GetSonIds($typeid).") ORDER BY arc.sortrank desc $limitsql";
	$dsql->SetQuery($query);
	$dsql->Execute('al');
	$dtp2 = new DedeTagParse();
	$dtp2->SetNameSpace('field', '[', ']');
	$dtp2->LoadString($innertext);
	$GLOBALS['autoindex'] = 0;
	$ids = array();
	for($i=0; $i<12; $i++)
	{
	for($j=0; $j<1; $j++)
	{
	if($row = $dsql->GetArray("al"))
	{
	$ids[] = $row['id'];
	//处理一些特殊字段
	$row['info'] = $row['infos'] = cn_substr($row['description'],$infolen);
	$row['id'] =  $row['id'];
	if($row['corank'] > 0 && $row['arcrank']==0)
	{
	$row['arcrank'] = $row['corank'];
	}
	$row['filename'] = $row['arcurl'] = GetFileUrl($row['id'],$row['typeid'],$row['senddate'],$row['title'],$row['ismake'],
	$row['arcrank'],$row['namerule'],$row['typedir'],$row['money'],$row['filename'],$row['moresite'],$row['siteurl'],$row['sitepath']);
	$row['typeurl'] = GetTypeUrl($row['typeid'],$row['typedir'],$row['isdefault'],$row['defaultname'],$row['ispart'],
	$row['namerule2'],$row['moresite'],$row['siteurl'],$row['sitepath']);
	if($row['litpic'] == '-' || $row['litpic'] == '')
	{
	$row['litpic'] = $GLOBALS['cfg_cmspath'].'/images/defaultpic.gif';
	}
	if(!preg_match("#^http:\/\/#", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y')
	{
	$row['litpic'] = $GLOBALS['cfg_mainsite'].$row['litpic'];
	}
	$row['picname'] = $row['litpic'];
	$row['stime'] = GetDateMK($row['pubdate']);
	$row['typelink'] = "<a href='".$row['typeurl']."'>".$row['typename']."</a>";
	$row['image'] = "<img src='".$row['picname']."' border='0′ width='$imgwidth' height='$imgheight' alt='".preg_replace("#['><]#", "", $row['title'])."'>";
	$row['imglink'] = "<a href='".$row['filename']."'>".$row['image']."</a>";
	$row['fulltitle'] = $row['title'];
	$row['title'] = cn_substr($row['title'],$titlelen);
	if($row['color']!='') $row['title'] = "<font color='".$row['color']."'>".$row['title']."</font>";

	if(preg_match('#b#', $row['flag'])) $row['title'] = "<strong>".$row['title']."</strong>";
	//$row['title'] = "<b>".$row['title']."</b>";
	$row['textlink'] = "<a href='".$row['filename']."'>".$row['title']."</a>";
	$row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
	$row['memberurl'] = $GLOBALS['cfg_memberurl'];
	$row['templeturl'] = $GLOBALS['cfg_templeturl'];
	if(is_array($dtp2->CTags))
	{
		foreach($dtp2->CTags as $k=>$ctag)
		{
			if($ctag->GetName()=='array')
			{
				$dtp2->Assign($k,$row);
			} else {
				if(isset($row[$ctag->GetName()])) $dtp2->Assign($k,$row[$ctag->GetName()]);
				else $dtp2->Assign($k,'');
			}
		}
		$GLOBALS['autoindex']++;
	}
	$artlist .= $dtp2->GetResult()."\r\n";
	}
	else {
		$artlist .= '';
	}
	}
	}
	$dsql->FreeResult("al");
}
else
{
	die(" Request Error! ");
}
	AjaxHead();
	echo $artlist;
exit();